import os
from pygments.formatters import HtmlFormatter

from django.core.management.base import BaseCommand


class Command(BaseCommand):
    help = 'Generate CSS file in settings.MEDIA_ROOT with a name pygments.css.for you to syntax colorize your code'
    args = 'you may change the file name'
    option_list = BaseCommand.option_list + (
        make_option('--css_file', default='pygments.css', dest='css_file',
            help='The output filename under settings.MEDIA_ROOT'),
    )
    
    def handle(self, *app_labels, **options):
        css_file = options.get('css_file', 'pygments.css')
        fullpath = os.path.join(settings.MEDIA_ROOT, css_file)
        f = open(path,'w')
        f.write(HtmlFormatter().get_style_defs('.highlight'))
        f.close()
        print '''
CSS File %s generated!

uncomment
##    (r'^test_syntax_colorize$', '{{ project_name }}.apps.syntax_colorize.index'),
in urls.py

uncomment
##  '{{ project_name }}.apps.syntax_colorize',
in settings.py

if you have changed the css_file name, you must apply this change to the following template too:
{{ project_name }}/apps/syntax_colorize/templates/syntax_colorize/index.html

goto http://localhost:8000/test_syntax_colorize/ to test it out!
'''
        
